package com.qf.controller;

import com.qf.pojo.request.TbFilmPictureReq;
import com.qf.pojo.request.TbThirdPictureReq;
import com.qf.pojo.response.BaseResponse;
import com.qf.service.TbFilmPictureService;
import com.qf.service.TbThirdPictureService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Api("理财图片管理器")
@RestController
@RequestMapping("/third")
public class TbThirdPictureController {
    @Autowired
    TbThirdPictureService tbThirdPictureService;
    @ApiOperation(value = "查询所有图片")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page",value = "当前页",required = true,dataType = "Integer"),
            @ApiImplicitParam(name = "size",value = "当前页显示多少行数据",required = true,dataType = "Integer")
    })
    @GetMapping("/findAll")
    @RequiresPermissions({"THIRD_FINDALL"})
    public BaseResponse findAll(@RequestParam("page") Integer page, @RequestParam("size") Integer size){
        return tbThirdPictureService.findAll(page,size);
    }
    @ApiOperation("修改或新增图片")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "tbThirdPictureReq",value = "图片请求对象",required = true,dataType = "TbThirdPictureReq")
    })
    @PostMapping("/updateOrSave")
    @RequiresPermissions({"THIRD_UPDATEORSAVE"})
    public BaseResponse updateOrSave(@RequestBody TbThirdPictureReq tbThirdPictureReq){
        return tbThirdPictureService.updateOrSave(tbThirdPictureReq);
    }
    @ApiOperation("根据id删除某个图片")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "map",value = "图片id",required = true,dataType = "Map")
    })
    @DeleteMapping("/deleteById")
    @RequiresPermissions({"THIRD_DELETE"})
    public BaseResponse deleteById(@RequestBody Map map){
        return tbThirdPictureService.deleteById(Integer.valueOf(map.get("id").toString()));
    }
}
